package gameobject;

import simulation.Game;

/**
 * Missile class that tells the game
 * how a missile is to react.
 *
 */
public class Missile extends Sprite {
    private Sprite myOwner;

    /**
     * Missile constructor.
     * @param game which the missile belongs to
     * @param owner sprite that owns the missile
     * @param x the starting x pos
     * @param y starting y pos
     * @param dx starting x acc
     * @param dy starting y acc
     * @param speed starting speed
     * @param hp starting health
     * @param damage starting damage to inflict
     */
    public Missile (Game game, Sprite owner, int x, int y,
            Number dx, Number dy, Number speed,
                    Number hp, Number damage) {
        super(game, dx, dy, speed, hp, damage);
        setImage(getResource("MissileImage"));
        setX(x);
        setY(y);
        myOwner = owner;
    }

    @Override
    public void collide(Sprite other) {
        if (other != myOwner) {
            die();
        }
    }
}
